package com.example.mobile2032021606130zlw0408;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.Guideline;

public class MainActivity extends AppCompatActivity {
    String xuan;
    private TextView textView;
    private CheckBox checkBoxYingqing;
    private CheckBox checkBox2Boli;
    private CheckBox checkBox3Fangxiangpan;
    private Button buttonGoumai;
    private TextView textView2;
    private Guideline guideline;
    private TextView textXianshi;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        textView = (TextView) findViewById(R.id.textView);
        checkBoxYingqing = (CheckBox) findViewById(R.id.checkBox_yingqing);
        checkBox2Boli = (CheckBox) findViewById(R.id.checkBox2_boli);
        checkBox3Fangxiangpan = (CheckBox) findViewById(R.id.checkBox3_fangxiangpan);
        buttonGoumai = (Button) findViewById(R.id.button_goumai);
        textView2 = (TextView) findViewById(R.id.textView2);
        guideline = (Guideline) findViewById(R.id.guideline);
        textXianshi = (TextView) findViewById(R.id.text_xianshi);
        buttonGoumai.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "完成了！", Toast.LENGTH_SHORT).show();
               if (checkBoxYingqing.isChecked()){
                   textXianshi.append(checkBoxYingqing.getText().toString());
               }else {
                   textXianshi.append("");
               }
                if (checkBox2Boli.isChecked()){
                    textXianshi.append("\n"+checkBox2Boli.getText().toString());
                }else {
                    textXianshi.append("");
                }
                if (checkBox3Fangxiangpan.isChecked()){
                    textXianshi.append("\n"+checkBox3Fangxiangpan.getText().toString());
                }else {
                    textXianshi.append("");
                }
            }
        });
    }
}